Tutorials Navigation
C Programming Tutorial 5, If Statement Part 1
Tutorial Name: C Programming Tutorial 5, If Statement Part 1
Category: PC Tutorials
Submitted By: Nissan
Date Added:
Comments: 2
Views: 1,115
Related Forum: PC Building Forum
Share:
C Programming Tutorial 5, If Statement Part 1
The program we are going to be using to learn C programming language is "CodeBlocks" and here is a link to the download its a free program.
Link : [ Register or Signin to view external links. ]
All of these tutorials are going to be done in an console application.
in this tutorial i will be showing you how to get input from user
So lets get started :
In this tutorial we are going to begin looking into if statements and an if statement will allow you to test a condition for example lets just say we wanted to check if i is equal to 6 we only want something to happen if i is equal to 6 so in order to test that what you are going to want to do is just type out :
if( i == 6){
}
now the reason why we want double equals is because the single equals will just assign an variable value so the single equals will just assign i to 6 how ever the double equals simply checks if i equal to 6
now lets just say we wanted to print out hello if i equal to 6 that would look like :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 6;
if(i == 6){
printf("Hello");
}
return 0;
}
once again what this is going to do right here is create a new integer variable called i and set it equal to 6 then ifs going to check if i is equal to 6 then if i is equal to 6 its going to print out hello on the screen and if i is not equal to 6 then it will just exit the program so now lets go ahead and run the program and make sure it works and we should get hello on the screen because i is equal to 6.
[ Register or Signin to view external links. ]
and as you can see it works we do get hello on the screen now let change the value of i to 7 now your code will look like :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i = 7;
if(i == 6){
printf("Hello");
}
return 0;
}
now you can see we do not get anything on the screen because i is not equal to 6:
[ Register or Signin to view external links. ]
I Hope You Have Learned Something In This Tutorial
Ratings
Comments
Related Tutorials
- 01. Emulating Xbox 360 on PC for Running COD4 With Mods(3,492)
- 02. How to: Matrix Numbers | Batch File(1,903)
- 03. How to Password Protect Files on Windows(857)
- 04. How to play Socom 2/3/ and Combined Assault on PC(6,716)
- 05. Modern Warfare 2 Vac Ban Bypass Tutorial(6,133)
- 06. How to embed an image on TheTechGame(3,098)
- 07. [PC] NIOH 2 OTHER USER SAVE RESIGN(12,981)
- 08. Host bot lobbies! Full Tutorial!(11,241)
- 09. Unban yourself [Plutonium BO2](14,240)
- 10. Fall Guys - How to Change Your Name Color on Fall Guys(8,385)
- 11. Best Crosshair Settings for Valorant(6,525)
- 12. Othercide The Surgeon Boss Guide(2,539)
- 13. Othercide Remembrances Unlock Guide(4,460)
- 14. Othercide Beginners Tips and Tricks(2,708)
- 15. How to Fix Grounded Crashes, Loading Time, Low FPS and Other(4,845)
"C Programming Tutorial 5, If Statement Part 1" :: Login/Create an Account :: 2 comments