Posts

To check the age and given the marks are not in c programming

  #include <stdio.h> #include <conio.h> int main() { int age,marks; printf( "enter your age\n" ); scanf ( "%d" ,&age); printf( "enter your marks\n" ); scanf( "%d" ,&marks); switch (age) { case 3: printf( "the age is 3\n" ); switch (marks) { case 45: printf( "your marks are 45" ); break ; default : printf( "your marks are not 45" ); } break ; } return 0; } Output:enter your age 3 enter your marks 45 the age is 3 your marks are 45

To check the maximum number in switch case in c programming.

#include <stdio.h> #include <conio.h> int main() {     int num1,num2;     printf( "Enter two numbers to find maximum: " );     scanf( "%d%d" , &num1, &num2);     switch (num1<num2)     {       case 0:       printf( "%d is maximum" , num1);       break ;       case 1:       printf( "%d is maximum" , num2);       break ;        } return 0; } Output: enter two numbers to find maximum:8                                                               7                          ...

Even or odd in c programming.

  #include <stdio.h> #include <conio.h> int main() { int num; Printf( "enter the number" ); scanf( "%d" ,&num); if (num % 2==0) printf( "number is even=%d" ,num); else printf( "number is odd=%d" ,num); return 0; } Output:enter the number 7 number is odd=7  enter the number 8 number is even=8

Simple interests in c programming

#include<stdio.h> #include<conio.h> int main() { int p,r,t,pi; printf("inter the value of principal,rate,time"); scanf("%d%d%d",&p,&r,&t); Pi=(p*r*t)/100; printf(" pi = %d",pi); return 0; }   Output: inter the value of principal,rate,time 300 12 6  pi = 216

Reverse table in c programming.

  #include <stdio.h> #include <conio.h> int main() { int p,i; printf( "enter the integer number with multiplication table" ); scanf( "%d" ,&p); for (i=10;i>=1;i--) {   printf( "%d*%d=%d" ,p,i,p*i); }   return 0; }    Output:enter the integer number with multiplication table 9 9*10=90 9*9=81 9*8=72 9*7=63 9*6=54 9*5=45 9*4=36 9*3=27 9*2=18 9*1=9

Table printing in c programming

  #include <stdio.h> #include <conio.h> int main() { int p,i; printf( "enter the integer number with multiplication table" ); scanf( "%d" ,&p); for (i=1;i<=10;i++) {   printf( "%d*%d=%d" ,p,i,p*i); }   return 0; } Output:enter the integer number with multiplication table 7 7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 7*8=56 7*9=63 7*10=70