Skip to main content

Posts

Showing posts with the label floyd's triangle in c

Sample C Program To Add Two Numbers Using Pointers.

#include <stdio.h> #include <conio.h> int main() { int x, y, *p, *q, sum; printf(" Enter two integers to add " ); scanf(" %d %d ", &x, &y ); p = &x; q = &y; sum = *p + *q; printf(" Sum of entered numbers = %d\n ", sum ); getch(); return 0; } OUTPUT: Enter two integers to add 3 6 Sum of entered numbers = 9 Sample C Program To Print Floyd’s Triangle. #include <stdio.h> #include <conio.h> main() { int n, i, c, number = 1; printf(" Enter the number of rows of Floyd's triangle you want " ); scanf(" %d ", &n ); for ( i = 1 ; i <= n ; i++ )   {      for ( c = 1 ; c <= i ; c++ )        {           printf(" %d ", number );           number++;        }        printf(" \n " );   } getch(); return 0; } OUTPUT: Enter the number of rows of Floyd’s triang...