#include<stdio.h>
int main()
{ int x=3,y=5,a=7,b=6,c=2;
printf("%d",x*y<(a+b)||c);
return 0;
}
//comment the output👇
int main()
{ int x=3,y=5,a=7,b=6,c=2;
printf("%d",x*y<(a+b)||c);
return 0;
}
//comment the output👇
👍4
//Program to print following pattrn.
/* *****
*****
*****
*****
*****
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
/* *****
*****
*****
*****
*****
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
👍6❤2
//Program to print following pattrn.
/* *
**
***
****
*****
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
/* *
**
***
****
*****
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
return 0;
}
❤6👍4
//Program to print following pattrn.
/* 1
12
123
1234
12345
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
/* 1
12
123
1234
12345
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
👍5
//Program to print following pattrn.
/* 1
22
333
4444
55555
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
return 0;
}
/* 1
22
333
4444
55555
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",i);
}
printf("\n");
}
return 0;
}
👍6🔥1
//Program to print following pattrn.
/* 0
12
345
6789
*/
#include<stdio.h>
int main()
{ int i,j,count=0;
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
{
printf("%d",count);
count++;
}
printf("\n");
}
return 0;
}
/* 0
12
345
6789
*/
#include<stdio.h>
int main()
{ int i,j,count=0;
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
{
printf("%d",count);
count++;
}
printf("\n");
}
return 0;
}
👍10
//Program to print following pattrn.
/* a
ab
abc
abcd
abcde
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=97;i<=101;i++)
{
for(j=97;j<=i;j++)
{
printf("%c",j);
}
printf("\n");
}
return 0;
}
/* a
ab
abc
abcd
abcde
*/
#include<stdio.h>
int main()
{ int i,j;
for(i=97;i<=101;i++)
{
for(j=97;j<=i;j++)
{
printf("%c",j);
}
printf("\n");
}
return 0;
}
👍6❤4
//Program to print following pattern.
/* 1
12
123
1234
12345
*/
#include<stdio.h>
int main()
{ int i,j,k;
for(i=1;i<=5;i++)
{
for(k=5;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
/* 1
12
123
1234
12345
*/
#include<stdio.h>
int main()
{ int i,j,k;
for(i=1;i<=5;i++)
{
for(k=5;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;
}
👍5🔥1
//Program to print following pattern.
/* 1
121
12321
1234321
123454321
*/
#include<stdio.h>
int main()
{ int i,j,k,l;
for(i=1;i<=5;i++)
{
for(k=5;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(l=j-2;l>0;l--)
{
printf("%d",l);
}
printf("\n");
}
return 0;
}
/* 1
121
12321
1234321
123454321
*/
#include<stdio.h>
int main()
{ int i,j,k,l;
for(i=1;i<=5;i++)
{
for(k=5;k>i;k--)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(l=j-2;l>0;l--)
{
printf("%d",l);
}
printf("\n");
}
return 0;
}
👍27❤10💯3😁2🥰1👏1
//calculate power of a number without using pow() function
#include<stdio.h>
int main()
{
int base,exp,res=1,i;
printf("Enter the base:");
scanf("%d",&base);
printf("Enter the exponent:");
scanf("%d",&exp);
for(i=1;i<=exp;i++)
{
res=res*base;
}
printf("%d to the power of %d is :%d",base,exp,res);
return 0;
}
#include<stdio.h>
int main()
{
int base,exp,res=1,i;
printf("Enter the base:");
scanf("%d",&base);
printf("Enter the exponent:");
scanf("%d",&exp);
for(i=1;i<=exp;i++)
{
res=res*base;
}
printf("%d to the power of %d is :%d",base,exp,res);
return 0;
}
👍11😁3
//program to print leap years from m to n'th year
#include<stdio.h>
int main()
{
int m,n;
printf("Enter the year m:");
scanf("%d",&m);
printf("Enter the year n:");
scanf("%d",&n);
do
{
if((m%4==0 && m%100!=0) || (m%400==0))
{
printf("%d is a leap year\n",m);
}
else{
printf("%d is not a leap year\n",m);
}
m+=1;
}while(m<=n);
return 0;
}
#include<stdio.h>
int main()
{
int m,n;
printf("Enter the year m:");
scanf("%d",&m);
printf("Enter the year n:");
scanf("%d",&n);
do
{
if((m%4==0 && m%100!=0) || (m%400==0))
{
printf("%d is a leap year\n",m);
}
else{
printf("%d is not a leap year\n",m);
}
m+=1;
}while(m<=n);
return 0;
}
👍13❤2
👍24🔥2❤1
🤔41🤯28👍21❤7💯7😁4🔥2🥰2
What is an Array ?
An array is a collection of elements of the same data type, and all these elements are stored in contiguous memory locations, which means that they are placed next to each other in the memory. This arrangement makes it easy to access and manipulate individual elements within the array.
An array is a collection of elements of the same data type, and all these elements are stored in contiguous memory locations, which means that they are placed next to each other in the memory. This arrangement makes it easy to access and manipulate individual elements within the array.
👍46❤12🥰1
What is an Index?
To access an element in an array, we use its index. The index is a number that identifies the position of the element in the array. The first element in the array has index 0, the second element has index 1, and so on.
To access an element in an array, we use its index. The index is a number that identifies the position of the element in the array. The first element in the array has index 0, the second element has index 1, and so on.
👍32❤4🥰1👏1
What is address of an array ?
The address of an array is the address of its first element. This is because an array is simply a contiguous block of memory, with each element stored sequentially. The address of the first element is the starting address of that block of memory.
• It is important to note that the address of an array is different from the address of any individual element in the array.
• Usually address is in Hexadecimal form ,for understanding purpose we will take decimal numbers as addresses.
The address of an array is the address of its first element. This is because an array is simply a contiguous block of memory, with each element stored sequentially. The address of the first element is the starting address of that block of memory.
• It is important to note that the address of an array is different from the address of any individual element in the array.
• Usually address is in Hexadecimal form ,for understanding purpose we will take decimal numbers as addresses.
👍29❤4🤝1
>Classification of Arrays:
Arrays are classified into two types,
• Single-dimensional array:
A single-dimensional array is a linear list of elements of the same data type. Each element in the array is identified by its unique index, which is an integer value. The index of the first element in the array is always 0, and the index of the last element in the array is always one less than the total number of elements in the array.
• Multi-dimensional array:
A multi-dimensional array is a collection of data in multiple dimensions. A two-dimensional array, for example, can be visualized as a table with rows and columns. Each element in the array is identified by a unique set of indices, one index for each dimension.
Arrays are classified into two types,
• Single-dimensional array:
A single-dimensional array is a linear list of elements of the same data type. Each element in the array is identified by its unique index, which is an integer value. The index of the first element in the array is always 0, and the index of the last element in the array is always one less than the total number of elements in the array.
• Multi-dimensional array:
A multi-dimensional array is a collection of data in multiple dimensions. A two-dimensional array, for example, can be visualized as a table with rows and columns. Each element in the array is identified by a unique set of indices, one index for each dimension.
👍31❤12🔥2🤔2😁1