Posts

Showing posts from March, 2016

C program to find Transpose of Matrix.

This blog has been migrated to learn c programming for beginners Write a C program to find Transpose of Matrix  This C program prints the Transpose of supplied Matrix. C Program source code #include<stdio.h> #include<conio.h> #define MAX 100 int main() {  int i,j,r,c,m[MAX][MAX];  printf("Enter the order of matrix:\n");  scanf("%d%d",&c,&r);  printf("Enter a %d*%d matrix:\n",c,r);  for(i=0;i<c;i++)  {   for(j=0;j<r;j++)   {    scanf("%d",&m[i][j]);   }  }  printf("Matrix before transpose:\n");  for(i=0;i<c;i++)  {   for(j=0;j<r;j++)   {    printf("%d\t",m[i][j]);   }   printf("\n");  }  printf("Matrix after transpose:\n");  for(j=0;j<r;j++)  {   for(i=0;i<c;i++)   {    printf("%d\t",m[i][j]);   }   printf(...

C program to check if the supplied year is leap year or not.

This blog has been migrated to learn c programming for beginners Write a C program to check if the supplied year is leap year or not.  This C program check if the supplied year is leap year or not. C Program source code #include<stdio.h> #include<conio.h> int main() {  int y;  printf("Enter a year:\n");  scanf("%d",&y);  if(y%400==0)  {   printf("Its a leap year.");  }  else if(y%100==0)  {   printf("Its not a leap year,");  }  else if(y%4==0)  {   printf("Its a leap year,");  }  else  {   printf("Its not a leap year,");  }  getch();  return(0); } You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address * C program to check i...

C program to print even numbers between given two numbers.

This blog has been migrated to learn c programming for beginners Write a C program print even numbers between given two numbers. This C program prints the even number between the two number supplied by user C Program source code #include<stdio.h> #include<conio.h> int main() {  int i,n1,n2;  printf("Enter any two numbers:\n");  scanf("%d%d",&n1,&n2);  for(i=n1;i<=n2;i++)  {   if(i%2==0)   {    printf("%d\t",i);   }  }  printf("\nThese are the even numbers between those two numbers.");  getch();  return(0); } You can Browse related article below for more information and program code related to different math operation.  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address * C program to print even numbers between given two numbers.

Structure Learning for both novices and advanced programmers

Image
This blog has been migrated to learn c programming for beginners Structure The meaning of structure is the quality of being organized in general term. To understand the structure in programming language you must be able to link it with general meaning 1) How can we link it with general meaning? 2) What is structure in c? In programming structure is the collection of various data of different data type. We can connect it with the class of java or other OOP language. As class has object which have property and method, But here we have an object and its property or value. Structure helps to bring real physical object into virtual computer world. A simple structure can be Student with property 1) Name 2) Roll number 3) Age etc. 1) How structure is different from array and variable? 2) What is advantage of structure? Structure is used for data handling operation. It can be good to think that there are already other syntax that can handle data, then why is the need of St...

C Programming Quiz online on input and output

Image
This blog has been migrated to learn c programming for beginners Following quiz provides Multiple Choice Questions (MCQs) related to C Programming input and output . You will have to read all the given answers and click over the correct answer. You are given 3 to 4 options , you have to click on option  until you are right. c programming quiz on input and output 1.What is difference between getch() and getche()? getch() do not take'e' TRY AGAIN getch() do not show input data in screen but getche() show input data in screen perfect getch() is used for all media but getche() is not. Try again 2.scanf("%3f%4f",&x,&y); Input is: 5.93 , 65.87 5.93 is stored in x and 65.87 is stored in y Try again 5.9 is stored in x and 65.8 is stored in y Try again 5.9 is stored in x and 3.00 is stored in y WOW , you are write 3.What is use of escape character '\b'? It backs the program Try again It moves the control to first position Try ag...

Fibonacci series using recursive function

Write a program using recursive to read positive number  and determine the fibonacci series of n terms C Program source code #include<stdio.h> #include<conio.h> int fibbo(int n1, int n2); int n ,no=1 ,temp; int main () { int n1=0,n2=1; printf("Enter number of terms in fibbonaccic series:"); scanf("%d",&n); printf("\n"); printf("fibbonaccic series of %d term are :\n" , n); printf("%d\t",n1); printf("%d\t",n2); fibbo(n1,n2); getch(); return 0 ; } int fibbo(int n1 , int n2) { if(no==n-1) return 0; temp = n1; n1=n2; n2 =n1+ temp; printf("%d\t",n2); no++; fibbo(n1,n2); } You can Browse related article below for more information and program code related to string function  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address * Fibonacci series using recursiv...

Multidimensional array in c

A multinational company has hired 3 sales persons for marketing/selling its 3 different products in Kathmandu .Each sales person sells each of these products. Write a c program to read number of each product sold by all sales-persons. Calculate total sells of each item and the total sells of each sales-person . Use array C Program source code #include <stdio.h> #include <conio.h> #include <string.h> int main() { int pro[3][3],sum=0; int j ,i ; char per[3][10]={ "first","second","third"}; for (i=0 ; i<3 ; i++) { for(j=0 ; j<3 ; j++) { printf("enter number of selling of %s person %s product:" , per[i] ,per[j] ); scanf("%d", &pro[i][j]); printf("\n"); } } for (i=0 ; i<3 ; i++) { for(j=0 ; j<3 ; j++) { sum = sum + pro[j][i]; } printf("Total sell of %s item is:%d\n",per[i], sum); sum=0; } for (i=0 ; i<3 ; i++) ...

Print pattern in c - star pattern-5

Image
Print pattern in c - star pattern Write a program to print following pattern * ** *** **** Program code #include <stdio.h> int main () { int rows , i , j , space ; printf ( "Enter number of rows: " ); scanf ( "%d" ,& rows ); for ( i = rows ; i >= 1 ;-- i ) { for ( space = 0 ; space < rows - i ;++ space ) printf ( " " ); for ( j = i ; j <= 2 * i - 1 ;++ j ) printf ( "* " ); for ( j = 0 ; j < i - 1 ;++ j ) printf ( "* " ); printf ( "\n" ); } return 0 ; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

C program source code to print reversed string using string function

C program source code to print reversed string using string function Write a C program  to print reversed string using string function C Program source code #include<stdio.h> #include<conio.h> #include<string.h> int main() { char name[100]; printf("Enter any character:"); gets(name); strrev(name); printf("The character after reversing is:"); puts(name); getch(); return 0; } You can Browse related article below for more information and program code related to string function  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

C program source code to print string length using strlen

C program source code to print string length using strlen Write a C program  to print  string length using strlen C Program source code #include<stdio.h> #include<conio.h> #include<string.h> int main() { char name[100]; printf("Enter the character:"); gets(name); int k; k=strlen(name); printf("The length of the string is:%d",k); getch(); return 0; } You can Browse related article below for more information and program code related to string function  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

C program source code to print reversed string

C program source code to print reversed string Write a C program  to print reversed string C Program source code #include<stdio.h> #include<string.h> #include<conio.h> int main() { char a[100]; int i,n; printf("Enter any word:\n"); gets(a); n=strlen(a); printf("The reversed array is:\n" ); for(i=n-1; i>=0; i--) printf("%c",a[i]); getch(); return 0; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

C program source code to create file in file handling

C program source code to create file in file handling Write a C program  to create file in file handling C Program source code #include<stdio.h> #include<conio.h> int main() { FILE *fptr; fptr=fopen("Test.txt","w"); if(fptr==NULL) { printf("\nFile can not be opened"); } else { printf("File is succesfully created"); } fputs("welcome to c programming",fptr); fclose(fptr); getch(); return 0; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

c program to sort element of one dimensional array in ascending or descending order

c program to sort element of one dimensional array in ascending or descending order Write a program  to sort element of one dimensional array in ascending or descending order Ascending #include<stdio.h> #include<conio.h> int main() { int i,j,n,temp,a[1000]; printf("Enter the number of elements in the array:"); scanf("%d",&n); for(i=0; i<n; i++){ printf("Enter the %d elements of array:",i); scanf("%d",&a[i]); } for(i=0; i<n; i++) { for(j = i+1 ; j<n ; j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } printf("The sorted list in ascending order is:"); for(i=0; i<n; i++) printf("%d\n",a[i]); getch(); return 0; } Descending #include<stdio.h> #include<conio.h> int main() { int i,j,n,temp,a[1000]; printf("Enter the number of elements in the array:"); scanf("%d",&n); for(i=0; i<n; i++){ printf("Enter the %d elements of array:...

c-programming quiz

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming . You will have to read all the given answers and click over the correct answer. You are given 3 to 4 options , you have to click on option  until you are right. 1.Which argument is called actual argument? Argument used in function prototype and function call TRY AGAIN Argument used in only function call perfect Argument used in function description Try again 1.Difference between puts and printf is? puts print in new line but printf print in same line WOW , you are write No difference Try again Printf is user defined function but puts is built-in function Try again

Print pattern in c - number pattern-13

Print pattern in c - number pattern Write a program to print following pattern 12345 4321 123 21 1 Program code int main() { int i,j,k; for(i=5;i>=1;i--) { if(i%2==1) k=1; else k=i; for(j=1;j<=i;j++) { printf("%d",k); if(i%2==1) k++; else k--; } printf("\n"); } return 0; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - number pattern-12

Print pattern in c - number pattern Write a program to print following pattern 11111 2222 333 44 5 Program code #include <stdio.h> int main() {     int i, j;     for(i=1;i<=5;i++)     {         for(j=5;j>=i;j--)         {             printf("%d",i);         }         printf("\n");     }     return 0; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - number pattern-11

Print pattern in c - number pattern Write a program to print following pattern 55555 4444 333 22 1 Program code #include <stdio.h> int main() {     int i, j;     for(i=5;i>=1;i--)     {         for(j=1;j<=i;j++)         {             printf("%d",i);         }         printf("\n");     }     return 0; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - star pattern-4

Print pattern in c - star pattern Write a program to print following pattern * * * * * * * * * * * * * * * * * * * * * * * * * Program code #include <stdio.h> int main () { int rows , i , j , space ; printf ( "Enter number of rows: " ); scanf ( "%d" ,& rows ); for ( i = rows ; i >= 1 ;-- i ) { for ( space = 0 ; space < rows - i ;++ space ) printf ( " " ); for ( j = i ; j <= 2 * i - 1 ;++ j ) printf ( "* " ); for ( j = 0 ; j < i - 1 ;++ j ) printf ( "* " ); printf ( "\n" ); } return 0 ; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address * ...

Print pattern in c - star pattern-3

Print pattern in c - star pattern Write a program to print following pattern * * * * * * * * * * * * * * * * * * * * * * * * * Program code #include <stdio.h> int main () { int i , space , rows , k = 0 ; printf ( "Enter the number of rows: " ); scanf ( "%d" ,& rows ); for ( i = 1 ; i <= rows ;++ i ) { for ( space = 1 ; space <= rows - i ;++ space ) { printf ( " " ); } while ( k != 2 * i - 1 ) { printf ( "* " ); ++ k ; } k = 0 ; printf ( "\n" ); } return 0 ; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - star pattern-2

Print pattern in c - star pattern Write a program to print following pattern * * * * * * * * * * * * * * * Program code #include <stdio.h> int main () { int i , j , rows ; printf ( "Enter the number of rows: " ); scanf ( "%d" ,& rows ); for ( i = rows ; i >= 1 ;-- i ) { for ( j = 1 ; j <= i ;++ j ) { printf ( "* " ); } printf ( "\n" ); } return 0 ; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - star pattern-1

Print pattern in c - star pattern Write a program to print following pattern * * * * * * * * * * * * * * * Program code #include <stdio.h> int main () { int i , j , rows ; printf ( "Enter the number of rows: " ); scanf ( "%d" ,& rows ); for ( i = 1 ; i <= rows ;++ i ) { for ( j = 1 ; j <= i ;++ j ) { printf ( "* " ); } printf ( "\n" ); } return 0 ; } You can Browse related article below for more information and program code related to recursive function call  Does above is helpful , Post you views in comment DO NOT MISS OTHER C PROGRAMMING TUTORIAL * indicates required Email Address *

Print pattern in c - number pattern -10

Image
Print pattern in c - number pattern Write a program to print following pattern 5 44 333 2222 11111 Program code #include <stdio.h> int main() { int i, j; for(i=5;i>=1;i--) { for(j=5;j>=i;j--) { printf("%d",i); } printf("\n"); } return 0; } Step by Step solution 1. Number of row -    Is has 5row  , so first loop will execute for 5 time #include <stdio.h> int main() {     int i, j;     for(i=5;i>=1;i--)     {...... }     return 0; } 2. Number of character -  It has only one type of character , so there will be only one nested loop #include <stdio.h> int main() { ...... for(j=5;j>=i;j--) { printf("%d",i); } printf("\n"); } 3.Number of column - It has 5 maximum column and is decreasing with row number , so the nested loop decrease it's re...

Print pattern in c - number pattern -9

Image
Print pattern in c - number pattern Write a program to print following pattern 1 22 333 4444 55555 Program code #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; } Step by Step solution 1. Number of row -    Is has 5row  , so first loop will execute for 5 time #include <stdio.h> int main() {     int i, j;     for(i=1;i<=5;i++)     {...... }     return 0; } 2. Number of character -  It has only one type of character , so there will be only one nested loop #include <stdio.h> int main() { ...... for(j=1;j<=i;j++) { printf("%d",i); } printf("\n"); } 3.Number of column - It has 5 maximum column and is decreasing with row number , so the nested loop decrease it's ...