Posts

  Q 1   - What is the output of the below code snippet? #include <stdio.h> main () { for ( 1 ; 2 ; 3 ) printf ( "Hello" ); } A - Infinite loop B - Prints “Hello” once. C - No output D - Compile error Answer : A Q 2 - What is the output of the following program? #include <stdio.h> main () { printf ( "\"); } A - \ B - \" C - " D - Compile error Answer : D Q 3 - Identify the invalid constant used in fseek() function as ‘whence’ reference. A - SEEK_SET B - SEEK_CUR C - SEEK_BEG D - SEEK_END Answer : C Q 4 - What is the output of the following program? #include <stdio.h> main () { char * s = "Hello, " "World!" ; printf ( "%s" , s ); } A - Hello, World! B - Hello, World! C - Hello D - Compile error Answer : A Q 5 - What is the output of the following program? #include <stdio.h> void main () { char * s = "C++...
  C Program to print Alphabet Triangle There are different triangles that can be printed. Triangles can be generated by alphabets or numbers. In this c program, we are going to print alphabet triangles . Let's see the c example to print alphabet triangle. #include<stdio.h>      #include<stdlib.h>    int  main(){      int  ch=65;          int  i,j,k,m;       system( "cls" );        for (i=1;i<=5;i++)         {              for (j=5;j>=i;j--)                 printf( " " );              for (k=1;k<=i;k++)          ...
Image
Matrix multiplication in C Matrix multiplication  in C: We can add, subtract, multiply and divide 2 matrices. To do so, we are taking input from the user for row number, column number, first matrix elements and second matrix elements. Then we are performing multiplication on the matrices entered by the user. In matrix multiplication  first matrix one row element is multiplied by second matrix all column elements . Let's try to understand the matrix multiplication of  2*2 and 3*3  matrices by the figure given below: Let's see the program of matrix multiplication in C. #include<stdio.h>      #include<stdlib.h>    int  main(){   int  a[10][10],b[10][10],mul[10][10],r,c,i,j,k;     system( "cls" );   printf( "enter the number of row=" );     scanf( "%d" ,&r);     printf( "enter the number of column=...
  C Program to reverse number We can reverse a number in c using loop and arithmetic operators. In this program, we are getting number as input from the user and reversing that number. Let's see a simple c example to reverse a given number. #include<stdio.h>      int  main()     {     int  n, reverse=0, rem;     printf( "Enter a number: " );       scanf( "%d" , &n);        while (n!=0)       {          rem=n%10;          reverse=reverse*10+rem;          n/=10;       }       printf( "Reversed Number: %d" ,reverse);     return  0;   }...