C_programs
C_programs
Chapter 10 & 11
Std 10th 1
Computer practical notes C language
scanf("%f",&cm);
m=cm/100.0;
printf(" %f Centimetre=%f meter\n",cm,m);
return 0;
}
#include<stdio.h>
int main()
{
int cost,qty;
float ans;
printf("\n Enter the cost and quantity-");
scanf("%d%d",&cost,&qty);
ans=cost/(float)qty;
printf("Cost of one item after type casting is %f\n",ans);
return 0;
}
Std 10th 2
Computer practical notes C language
Chapter 13
/* Program to calculate Bigger number between 2 numbers */ (7)
#include<stdio.h>
int main()
{
int a,b;
printf("\n Enter two values.-");
scanf("%d%d",&a,&b);
if(a>b)
{
printf("%d is bigger number\n”,a);
}
else
{
printf("%d is bigger number\n”,b);
}
return 0;
}
/* Program to find even or odd number (DIY Leap year)*/ Lab ex. 4
#include<stdio.h>
int main()
{
int n;
printf("\n Enter the value of any number.");
scanf("%d",&n);
if(n%2==0)
{
printf("\n The number =%d is even\n",n);
}
else
{
printf("\n The number =%d is odd\n",n);
}
return 0;
}
/*Program to check voting eligibility */ Lab ex. 2
#include<stdio.h>
int main()
{
int age;
printf(“Enter your age-“);
scanf(“%d”,&age);
if(age>=18)
{
printf(“You are %d years old so you are eligible for vote\n”,age);
}
else
{
printf(“You are %d years old so you are not eligible for vote\n”,age);
}
return 0;
}
/*Program to find positive or negative number */ Lab ex. 1
#include<stdio.h>
int main()
{
Std 10th 3
Computer practical notes C language
int n;
printf(“Enter any number-“);
scanf(“%d”,&n);
if(n==0)
{
printf(“%d is Zero\n”,n);
}
else if(n>0)
{
printf(“%d is Positive number \n”,n);
}
else
{
printf(“%d is Negative number \n”,no);
}
return 0;
}
/* Program of display Weekday name*/ (8)
#include<stdio.h>
int main()
{
int day;
printf("\n Enter the number of any day");
scanf(“%d”,&day;
switch(day)
{
case 1:
printf("Today is Sunday\n");
break;
case 2:
printf("Today is Monday\n");
break;
case 3:
printf("Today is Tuesday\n");
break;
case 4:
printf("Today is Wednesday\n");
break;
case 5:
printf("Today is Thrusday\n");
break;
case 6:
printf("Today is Friday\n");
break;
case 7:
printf("Today is Saturday\n");
break;
default:
printf("%d character not belong to week day number\n",day);
}
return 0;
}
Std 10th 4
Computer practical notes C language
#include<stdio.h>
int main()
{
char choice;
printf("\n Enter any letter to find vowel or not\n");
scanf(" %c",&choice);
switch(choice)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
printf("Entered %c letter is vowel \n",choice);
break;
default:
printf("Entered %c letter is a consonant \n ",choice);
break;
}
return 0;
}
Std 10th 5
Computer practical notes C language
Chapter 14
/* Program of Counting using for loop*/(9)
#include<stdio.h>
int main()
{
int i;
for(i=1;i<=10;i++)
printf(“%d\n”,i);
return 0;
}
/* Program of Counting using while loop*/(9.1)
#include<stdio.h>
int main()
{
int i=1;
while(i<=10)
{
printf(“%d\n”,i);
i++;
}
return 0;
}
/* Program of Counting using do-while loop*/(9.2)
#include<stdio.h>
int main()
{
int i=1;
do
{
printf(“%d\n”,i);
i++;
} while(i<=10);
return 0;
}
/*Program to series 2,4,6,8……. (Even numbers) (10) DIY Odd numbers */
#include<stdio.h>
int main()
{
int i;
for(i=2;i<=20;i=i+2)
printf(“%d\n”,i);
return 0;
}
/* Program to display reverse counting (10,9,8,7….) using for loop */(11)
#include<stdio.h>
int main()
{
int i;
for(i=10;i>=1;i--)
printf(“%d\n”,i);
return 0;
}
Std 10th 6
Computer practical notes C language
Std 10th 7