How to Write Correct Code in C Programming and Where to Begin
C Program to Print 2 15 41 80 132 197 275 366 Numbers Series
Ex: Write a C program to print 2 15 41 80 132 197 275 366 numbers series. How to write a C program to print 2 15 41 80 132 197 275 366 numbers series. C program to print 2 15 41 80 132 197 275 366 numbers series.
Input from user:
Enter the number: 8
Expected output:
2 15 41 80 132 197 275 366
C Program to Print 1 3 8 15 27 50 92 Number Series
C Program to Print Natural Numbers Series
Ex: Write a C program to print natural number series. How to write a C program to print natural number series. C program to print natural number series.
Input from user:
Enter the number: 8
Expected output:
1 2 3 4 5 6 7 8...
Series Programs in C Exercises and Solutions
Guess the Number Game in C (Project 2)
Guess the number game Program in C:
Quick links:
In these program we used two extra header files one is <stdlib.h> and second is <time.h>. <stdlib.h> header file used because,
Rock-Paper-Scissor Game In C (Project-1)
Rock-Paper-Scissor Game Project using C Language:
In these program we used two new header files one is <stdlib.h> and second is <time.h>. <stdlib.h> header file used because
Data Input and Output Functions in C Programming
Data Input and output functions in C:
The C programming language supports many library functions which includes a number of input/output functions. These functions are used to transfer the information between the computer and device(user).
Some basic input/output functions are:
- scanf() and printf(): These two functions are used to transfer the single characters, strings and numerical values.
- getchar() and putchar(): These two functions are used to transfer single characters.
- gets() and puts(): is used to input and output strings.
1. How to use scanf and printf functions:
scanf() function is used to take input from user(keyboard).
printf() function is used to display output on the screen.
Example Program:
#include<stdio.h>
void main()
{
int num;// variable definition
/*Display message and ask user to enter some number... using printf()*/
printf("Enter the number:");
/*Read the number entered by user... using scanf()*/
scanf("%d",&num);
/*Display the number with message...using printf() */
printf("You entered number is: %d",num);
}
In above program %d is used to scan the intiger value.
If value is char then we use %c.
If value is float then we use %f and so on...
Above program shows the following output:
2. How to use getchar and putchar functions in our program:
getchar() function reads a single character from the terminal and returns it as an intiger.
putchar() function is used to display these single character.
Example program:
#include<stdio.h>
void main()
{
int a;
printf("Enter a character:");
/*Here, getchar function is used to store the accepted character in variable a*/
a = getchar();
/*Display the character stored in variable a using putchar function*/
putchar(a);
}
Above program shows the following output:
3. How to use gets() and puts() function in C:
In simple words:
gets() function is used to accept string from user.
puts() function is used to display the string.
Example program:
#include<stdio.h>
void main()
{
//Declare character array to store string
char str[100];
printf("Enter a string: ");
/*store string in array str*/
gets(str);
/*Display string on the output screen*/
puts(str);
}
Above program shows the following output:
File Handling in C Exercises and Solutions
File handling functions in C:
Below table shows the file opening modes in C:
Exercises and Examples of File Handling in C:
C Pattern Programming Exercises and Examples
In this tutorial you will find lot of pattern programming exercises and examples. Pattern programming exercises manly used to enhance the logic of programmer, by solving this programs you can easily increase your logical thinking ability or also it will increase your loops and if-else statements knowledge.
Pattern programming Exercises and there solutions:
Thank you for visiting us....... keep visiting. Learn our more C programming exercises with their solutions.....😊