Welcome to the ekgurukul.com website! This Programming in C Tutorial helps you learn the concept of language quickly and effectively. If you are not sure where to start learning Programming in C language.
Website ekgurukul.com is a good place to start your Learning.
Programming in C and C++ is a foundational course in computer science. It teaches students the basics of programming in these two languages, which are widely used in the industry. The course covers topics such as:
Students will learn how to write efficient and well-structured code in C and C++. They will also learn how to use these languages to solve real-world problems.
The course is typically offered at the introductory level. It is a prerequisite for many other courses in computer science, such as data structures, algorithms, and operating systems.
If you are interested in a career in computer science, then learning C and C++ is a great way to start. These languages are essential for many software engineering jobs.
Here are some of the benefits of learning C and C++:
Let’s see what’s so special in Programming in C, what we can achieve with it, let's start Learning ...
Student can access the solutions for preparation competitive exams
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,s;
clrscr();
printf("Enter two no: ");
scanf("%d%d",&a,&b);
s=a+b;
printf("sum=%d",s);
getch();
}
Output:
Enter two no: 10 11
sum = 11
#include<stdio.h>
#include<conio.h>
void main()
{
int r;
float pi=3.14,area,ci;
clrscr();
printf("enter radius of circle: ");
scanf("%d",&r);
area=pi*r*r;
printf("area of circle=%f ",area);
ci=2*pi*r;
printf("circumference=%f ",ci);
getch();
}
Output:
enter radius of a circle: 5
area of circle=78.000
circumference=31.4
#include<stdio.h>
#include<conio.h>
void main()
{
int p,r,t,si;
clrscr();
printf("Enter Principle, Rate of interest & time to find simple interest: ");
scanf("%d%d%d",&p,&r,&t);
si=(p*r*t)/100;
printf("Simple intrest equal to %d",si);
getch();
}
Output:
Enter Principle, Rate of interest & time to find simple interest: 500
5
2
Simple interest equal to 50
#include<stdio.h>
#include<conio.h>
void main()
{
float c,f;
clrscr();
printf("enter temp in centigrade: ");
scanf("%f",&c);
f=(1.8*c)+32;
printf("temp in Fahrenheit=%f ",f);
getch();
}
Output:
Enter temp in centigrade: 32
Temp in Fahrenheit=89.59998
#include<stdio.h>
#include<conio.h>
void main()
{
int s1, s2, s3, s4, s5, sum, total=500;
float per;
clrscr();
printf("Enter marks of 5 subjects: ");
scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
sum=s1+s2+s3+s4+s5;
printf("sum=%d",sum);
per=(sum*100)/total;
printf("percentage=%f",per);
getch();
}
Output:
Enter marks of 5 subjects: 60 65 50 60 60
sum=300
percentage=60.000
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter value for a & b: ");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("after swapping the value of a & b: %d %d",a,b);
getch();
}
Output:
enter value for a & b: 4 5
after swapping the value of a & b: 5 4
#include<stdio.h>
#include<conio.h>
void main()
{
int n,a,r=0;
clrscr();
printf("enter any no to get its reverse: ");
scanf("%d",&n);
while(n>=1)
{
a=n%10;
r=r*10+a;
n=n/10;
}
printf("reverse=%d",r);
getch();
}
Output:
enter any no to get its reverse: 456
reverse=654
#include<stdio.h>
#include<conio.h>
void main()
{
int gs,bs,da,ta;
clrscr();
printf("enter basic salary: ");
scanf("%d",&bs);
da=(10*bs)/100;
ta=(12*bs)/100;
gs=bs+da+ta;
printf("gross salary=%d",gs);
getch();
}
Output:
enter basic salary: 100
gross salary=122
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("enter value of a, b & c: ");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("a is greatest");
if((b>c)&&(b>a))
printf("b is greatest");
if((c>a)&&(c>b))
printf("c is greatest");
getch();
}
Output:
enter value for a, b & c: 5
7
4
b is greatest
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("enter value for a & b: ");
scanf("%d%d",&a,&b);
(a>b)?printf("a is greater"):printf("b is greater");
getch();
}
Output:
enter value for a & b: 5 7
b is greater
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter any year: ");
scanf("%d",&n);
if(n%4==0)
printf("year is a leap year");
else
printf("year is not a leap year");
getch();
}
Output:
enter any year: 1947 year is not a leap year
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter any no: ");
scanf("%d",&n);
if(n%2==0)
printf("no is even");
else
printf("no is odd");
getch();
}
Output:
enter any no: 5 no is odd
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
printf("Read the integer from keyboard :- ");
scanf("%d",&x);
x<<=3;
y=x;
printf("\nThe left shifted data is = %d ",y);
getch();
}
Output:
Read the integer from keyboard :- 2
The left shifted data is = 16
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("enter m for Monday\nt for Tuesday\nw for Wednesday\nh for Thursday\nf for Friday\ns for Saturday\nu for Sunday);
scanf("%c",&ch);
switch(ch)
{
case 'm':
case 'M': printf("monday");
break;
case 't':
case 'T': printf("tuesday");
break;
case 'w':
case 'W': printf("wednesday");
break;
case 'h':
case 'H': printf("thursday");
break;
case 'f ':
case 'F': printf("friday");
break;
case 's':
case 'S': printf("saturday");
break;
case 'u':
case 'U': printf("sunday");
break;
default : printf("wrong input");
break;
}
getch();
}
Output:
enter m for Monday t for Tuesday
w for Wednesday h for Thursday
f for Friday
s for Saturday u for Sunday: f friday
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,s,m,su,d;
clrscr();
printf("enter two no's : ");
scanf("%d%d",&a,&b);
printf("enter 1 for sum\n2 for multiply\n3for subtraction\n4 for division: ");
scanf("%d",&n);
switch(n)
{
case 1:
s=a+b;
printf("sum=%d",s);
break;
case 2:
m=a*b;
printf("multiply=%d",m);
break;
case 3:
su=a-b;
printf("subtraction=%d",su);
break;
case 4:
d=a/b;
printf("divission=%d",d);
break;
default: printf("wrong input");
break;
}
getch();
}
Output:
enter two no's: 8 4
enter 1 for sum
2 for multiply
3 for subtraction
4 for division: 1
sum=12
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,n,s,m,su,d;
clrscr();
printf(“enter two nos : ”);
scanf(“%d%d”,&a,&b);
printf(“enter 1 for sum\n2 for multiply\n3for subtraction\n4 for division: ”);
scanf(“%d”,&n);
switch(n)
{
case 1:
s=a+b;
printf(“sum=%d”,s); break;
case 2:
m=a*b;
printf(“multiply=%d”,m); break;
case 3:
su=a-b;
printf(“subtraction=%d”,su); break;
case 4:
d=a/b;
printf(“divission=%d”,d); break;
default:
printf(“wrong input”); break;
}
getch();
}
Output:
enter two nos: 12 10
enter 1 for sum
2 for multiply
3 for subtraction
4 for division:
1
sum = 22
#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum=0;
clrscr();
for(i=1;i<=10;i++)
{
printf(“%d no is= %d\n”,i,I);
sum=sum+i;
}
printf(“sum =%d”,sum);
getch();
}
Output:
1 no is=1
2 no is=2
3 no is=3
4 no is=4
5 no is=5
6 no is=6
7 no is=7
8 no is=8
9 no is=9
10 no is=10
sum=55
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
printf(“ ”);
for(k=1; k<=i; k++)
printf(“*”);
printf(“\n”);
}
getch();
}
Output:
*
**
***
****
*****
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k;
clrscr();
for(i=1;i<=3;i++)
{
for(j=3;j>=i;j--)
printf(“ ”);
{
for(k=1;k<=i*2-1;k++)
printf(“*”);
}
printf(“\n”);
}
getch();
}
Output:
*
***
*****
#include<stdio.h>
#include<conio.h>
void main()
{
int a=1,b=1,c=0,i;
clrscr();
printf("%d\t%d\t",a,b);
for(i=0;i<=10;i++)
{
c=a+b; if(c<100)
{
printf("%d\t",c);
}
a=b; b=c;
}
getch();
}
Output:
1 1 2 3 5 8 13 21 34 55 89
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,fact=1;
clrscr();
printf(“Enter any no: ”);
scanf(“%d”,&n);
for(i=n;i>=1;i--)
{
fact=fact*i;
}
printf(“Factorial=%d”,fact);
getch();
}
Output:
Enter a no: 6
Factorial=720
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,r=0; clrscr();
printf(“Enter any no: ”);
scanf(“%d”,&n);
for(i=2;i<=n-1;i++)
{
if(n%i==0)
r=1;
break;
}
if(r==0)
printf(“prime no”);
else
printf(“Not prime”);
getch();
}
Output:
Enter any no: 16
Not prime
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0;
clrscr();
printf("Enter any no: ");
scanf("%d",&n);
printf("1");
for(i=2;i<=n-1;i++)
printf(" 1/%d +",i);
for(i=1;i<=n;i++)
sum=sum+i;
printf(" 1/%d",n);
printf("\nSum=1/%d",sum+1/n);
getch();
}
Output:
Enter any no: 7
1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7
Sum=1/28
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,sum=0;
clrscr();
printf("Enter any no: ");
scanf("%d",&n);
for(i=1;i<n;i=i+2)
{
printf("%d+",i); sum=sum+i;
}
printf("%d",n);
printf("\nsum=%d",sum+n);
getch();
}
Output:
Enter any no: 7
1+3+5+7
Sum=16
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Read the integers from keyboard:- ");
scanf("%d %d",&a,&b);
c=a&b;
printf("\nThe Answer after ANDing is: %d ",c);
getch();
}
Output:
Read the integers from keyboard:- 8 4
The Answer after ANDing is: 0
#include<stdio.h>
#include<conio.h>
void main()
{
int *p1,*p2,sum;
clrscr();
printf("enter two no’s: ");
scanf("%d%d",&*p1,&*p2);
sum=*p1+*p2;
printf("sum=%d",sum);
getch();
}
Output:
enter two no's: 10 20
sum=30
#include<stdio.h>
#include<conio.h>
void main()
{
int *p1,*p2,sum;
clrscr();
printf("enter two no’s: ");
scanf("%d%d",&*p1,&*p2);
sum=*p1+*p2;
printf("sum=%d",sum);
getch();
}
Output:
enter two no's: 10 20
sum=30
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,sum=0; float av;
clrscr();
printf("enter elements of an aaray: ");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
sum=sum+a[i];
printf("sum=%d",sum);
av=sum/10;
printf("average=%.2f",av);
getch();
}
Output:
enter elements of an array: 4 5 6 1 2 3 5 5 4 7
sum=42
average=4.22
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],max,i;
clrscr();
printf("enter element for the array: ");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
max=a[0];
for(i=1;i<5;i++)
{
if(max<a[i])
max=a[i];
}
printf("maximum no= %d",max);
getch();
}
Output:
enter elements for array: 5 4 7 1 2
maximum no= 7
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[3][2],i,j;
clrscr();
printf("enter value for a matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
printf("enter value for b matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&b[i][j]);
}
printf("\na matrix is\n\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(" %d ",a[i][j]);
}
printf("\n");
}
printf("\nb matrix is\n\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(" %d ",b[i][j]);
}
printf("\n");
}
getch();
}
Output:
enter value for a matrix: 7 8 9 4 5 6
enter value for b matrix: 3 2 1 4 5 6
a matrix is
7 8
9 4
5 6
b matrix is
3 2
1 4
5 6
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[3][2],c[3][2],i,j;
clrscr();
printf("Enter value for 1 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
printf("Enter value for 2 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
c[i][j]=a[i][j]+b[i][j];
}
printf("Sum of matrix is\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n");
}
getch();
}
Output:
Enter value for 1 matrix: 1 2 3 4 5 6
Enter value for 2 matrix: 4 5 6 1 3 2
Sum of matrix is
5 7
9 5
8 8
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],b[5],c[5],i;
clrscr();
printf("enter value for array a ");
for(i=0;i<5;i++)
scanf("%d",&a[i]);
printf("enter value for array b ");
for(i=0;i<5;i++)
scanf("%d",&b[i]);
for(i=0;i<5;i++)
c[i]=a[i]-b[i];
printf("subtraction");
for(i=0;i<5;i++)
printf(" %d ",c[i]);
getch();
}
Output:
enter value for array a: 7 8 9 4 5
enter value for array b: 4 5 6 1 2
subtraction 3 3 3 3 3
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[3][2],c[3][2],i,j;
clrscr();
printf("enter value for 1 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
printf("enter value for 2 matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&b[i][j]);
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
c[i][j]=a[i][j]*b[i][j];
}
printf("matrix is\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
{
printf(" %d ",c[i][j]);
}
printf("\n");
}
getch();
}
Output:
enter value for 1 matrix: 7 8 9 4 5 6
enter value for 2 matrix: 3 2 1 2 5 6
matrix is
21 16
9 8
25 36
#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][2],b[2][3],i,j;
clrscr();
printf("Enter value for matrix: ");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
scanf("%d",&a[i][j]);
}
printf("Matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
printf(" %d ",a[i][j]);
printf("\n");
}
for(i=0;i<3;i++)
{
for(j=0;j<2;j++)
b[j][i]=a[i][j];
}
printf("Transpose matrix:\n");
for(i=0;i<2;i++)
{
for(j=0;j<3;j++)
printf(" %d ",b[i][j]);
printf("\n");
}
getch();
}
Output:
Enter value for matrix: 4 5 6 1 2 3
Matrix:
4 5
6 1
2 3
Transpose matrix:
4 6 2
5 1 3
#include<stdio.h>
#include<conio.h>
void main()
{
int max,i,*a[5];
clrscr();
printf("enter element for the array: ");
for(i=0;i<5;i++)
scanf("%d",&*a[i]);
max=*a[0];
for(i=1;i<5;i++)
{
if(max<*a[i])
max=*a[i];
}
printf("maximum no= %d",max);
getch();
}
Output:
enter elements for array: 5 4 7 1 2
maximum no= 7
#include<stdio.h>
#include<conio.h>
void main()
{
char a[50];
clrscr();
printf("enter any string: ");
gets(a);
puts(a);
getch();
}
Output:
enter any string: hi everyone
hi everyone
#include<stdio.h>
#include<conio.h>
void main()
{
int rev(int); int r,a;
clrscr();
printf("enter any no: ");
scanf("%d",&a);
r=rev(a);
printf("square is : %d",r);
getch();
}
int rev(int x)
{
return(x*x);
}
Output:
enter any no: 5
square is : 25
#include<stdio.h>
#include<conio.h>
void main()
{
void swap(int,int);
int a,b,r;
clrscr();
printf("enter value for a&b: ");
scanf("%d%d",&a,&b);
swap(a,b);
getch();
}
void swap(int a,int b)
{
int temp; temp=a; a=b; b=temp;
printf("after swapping the value for a & b is : %d %d",a,b);
}
Output:
enter value for a&b: 4 5
after swapping the value for a & b : 5 4
#include<stdio.h>
#include<conio.h>
void main()
{
int a,f;
int fact(int);
clrscr();
printf("enter a no: ");
scanf("%d",&a);
f=fact(a);
printf("factorial= %d",f);
getch();
}
int fact(int x)
{
int fac=1,i;
for(i=x;i>=1;i--)
fac=fac*i;
return(fac);
}
Output:
enter a no: 5
factorial = 120
#include<stdio.h>
#include<conio.h>
void main()
{
void table();
clrscr();
table();
getch();
}
void table()
{
int n,i,r;
printf("enter a no to know table: ");
scanf("%d",&n);
for(i=1;i<=10;i++)
{
r=n*i;
printf("%d*%d=%d\n",n,i,r);
}
}
Output:
enter a no to know table: 2
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,swap();
clrscr();
a=5; b=10;
printf("value of a=%d & value of b=%d before swap ",a,b);
swap(a,b);
printf("\nvalue of a =%d & b=%d after swap",a,b);
getch();
}
int swap(int x,int y)
{
int temp; temp=x; x=y; y=temp;
}
Output:
value of a=5 & value of b=10 before swap
value of a=5 & b=10 after swap
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,*aa,*bb,swap();
clrscr();
a=5; b=10;
aa=&a; bb=&b;
printf("value of a= %d & value of b=%d before swap",a,b);
swap(aa,bb);
printf("\nvalue of a=%d & b=%d after swap",a,b);
getch();
}
int swap(int *x,int *y)
{
int temp; temp=*x;
*x=*y;
*y=temp;
}
Output:
value of a= 5 & value of b=10 before swap
value of a=10 & b=5 after swap
#include<stdio.h>
#include<conio.h>
void main()
{
void max();
clrscr();
max();
getch();
}
void max()
{
int a[5],max,n,i;
printf("How many no’s you want to enter: ");
scanf("%d",&n);
printf("Enter element for the array: ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
max=a[0];
for(i=1;i<5;i++)
{
if(max<a[i])
max=a[i];
}
printf("maximum no= %d",max);
}
Output:
How many nos you want to enter: 4
Enter element for array: 4 5 6 1
maximum no: 6
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
clrscr();
printf("enter number: ");
scanf("%d",&n);
if(n<0)
printf("invalid number");
else
printf("%d!=%d",n,fact(n));
getch();
}
int fact(int x)
{
if(x==0)
return 1;
else
return(x*fact(x-1));
}
Output:
enter number: 5
5! =120
#include<stdio.h>
#include<conio.h>
void main()
{
char s1[20],s2[20];
clrscr();
printf("enter a string: ");
scanf("%s",s1);
strcpy(s2,s1);
strrev(s2);
if(strcmp(s1,s2)==0)
printf("string is a palindrome");
else
printf("not a palindrome string");
getch();
}
Output:
enter a string: abc
not a palindrome string
#include<stdio.h>
#include<conio.h>
void main()
{
file *fp,*fp1; char c;
clrscr();
fp=fopen("test.c","w");
printf("\nenter the contents for file1(#.end)\n");
c=getchar();
while(c!='#')
{
fputc(c,fp);
c=getchar();
}
rewind(fp);
fp=fopen("test.c","r");
fp1=fopen("tes.c","w");
c=fgetc(fp);
while(c!=eof)
{
fputc(c,fp);
c=fgetc(fp);
}
fclose(fp);
fclose(fp1);
fp1=fopen("tes.c","r");
c=fgetc(fp1);
printf("\nthe contents in file 2\n");
while(c!=eof)
{
putchar(c);
c=fgetc(fp1);
}
fclose(fp1);
getch();
}
Output:
enter the contents of file1(#-end) good morning#
the contents of file2 good morning
#include<stdio.h>
#include<conio.h>
void main()
{
int a[50],b[50],n1,n2,i,x;
clrscr();
printf("enter the number of elements in the first array");
scanf("%d",&n1);
printf("enter the elements\n");
for(i=0;i<n1;i++)
{
printf("enter a[%d]",i+1);
scanf("%d",&a[i]);
}
printf("enter the number of elements in the second array");
scanf("%d",&n2);
printf("enter the elements\n");
for(i=0;i<n2;i++)
{
printf("enter b[%d]",i+1);
scanf("%d",&b[i]);
}
for(x=0;x<n1;x++)
{
for(i=0;i<n2;i++)
{
if(b[i]==a[x])
{
b[i]=' ';
}
}
}
for(i=0;i<n1;i++)
{
printf("%d",a[i]);
}
for(i=0;i<n2;i++)
{
if(b[i]=='';)
continue;
else
printf("%d",b[i]);
}
getch();
}
Output:
Enter the number of elements in the first array 3
Enter the elements 3 5 7
Enter the number of elements in the first array 3
Enter the elements 2 5 9
3 5 7 2 9
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
void main()
{
char s[100];
int vow=0,cons=0,spc=0,punc=0,l,i;
clrscr();
printf("enter the statement\n");
gets(s);
l=strlen(s);
for(i=0;i<l;i++)
{
if(isalpha(s[i]))
{
if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u')
{
vow++;
}
else
{
cons++;
}
}
if(isspace(s[i])
{
spc++;
}
if(ispunct(s[i]))
{
punc++;
}
}
printf("\nno.of words=%d",spc+1);
printf("\nno.of vowels=%d",vow);
printf("\nno.of consonants=%d",cons);
printf("\nno.of space=%d",spc);
printf("\nno.on special characters=%d",punc);
getch();
}
Output:
Enter the statement
*Nothing is impossible in the world. No.of words=6
No.of vowels=10 No.of consonants=19 No.of space=5
No.of special characters=1
#include<stdio.h>
#include<conio.h>
void main()
{
Enum month(Jan, Feb, Mar, Apr, May, June, July, Aug,Sep, Oct, Nov, Dec)
clrscr();
printf("Jan=%d", Jan);
printf("Feb=%d", Feb);
printf("June=%d", June);
printf("Dec=%d", Dec);
}
Output:
Jan = 0 Feb = 1 June = 5 Dec = 11
#include <stdio.h>
int main()
{
int arr[2][2], n;
// enter the scalar value
scanf("%d", &n);
// input the matrix values
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 2; j++){
scanf("%d", &arr[i][j]);
}
}
// multiply every value of matrix with scalar value
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 2; j++){
arr[i][j] = arr[i][j] * n;
}
}
// print the updated matrix values
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 2; j++){
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}