Friday, 3 March 2017

New line character '\n'


#include<stdio.h>

int main()
{

printf("Hello there buddyy?");
printf("are u confused with the \n new line character '\n' ");    //observe that whenever the compiler encounter '\n cursor jumps to the next line'

printf("\n");
printf("with using  new line character at the end of the line \n");
printf("\n");

printf("Hello there buddyy? \n");                              //new line character takes the cursor to the new line
printf("observer the difference with the new line line character introduced in the above line!!! isnt it amazing ");

return 0;
}

Using Scanf statements



//This program is to add two numbers with scanf function!!!

#include<stdio.h>

int main()
{


// now lets get the data to be added from the User using a keyboard
int input1,input2,sum;
printf("add two numbers of your choice\n");
printf("Enter the first number\n");
//scanf is a inbuilt function which is defined in a stdio.h header file,it is used to read the data from the keyboard
scanf("%d",&input1);
// "&" here ampersand means address
// address of input1 is specified,so that the value is stored in the known address
printf("Enter the second number\n");
scanf("%d",&input2);
sum=input1+input2;
printf(" First_No that u entered:%d,\n Second_no that u entered:%d,\n therefore sum of two numbers:%d",input1,input2,sum);

}

Arithmatic operation using C (addition of two numbers)

//This program is to add two numbers

#include<stdio.h>

int main()
{
printf("%d \n",10+20);  //Here %d is a format specifier to display a integer value

//Variables
//In above example we cannot change the data 10+20=30 and the statements prints "30" at the output

//but the code will not be general! and always the output will be "30"
//So to write a general program to add 2 numbers we need a variable
//variable is a space in the computer memory to store a data
//for proper utilization of the memory space we have different data types to store different numbers
// ex: signed/unsigned char,int,float and the size allocated for this variables varies according to the size of your machine (16bit/32bit/64bit OS)

//lets add 2 integers


int x,z;                //here x is a integer variable.This statement is called 'vriable declaration'
x=10;                 // variable assignment
int y=34;            //variable initialization
z=x+y;

printf("The sum of two numbers is\n");
printf("sum=%d \n",x=y);

printf("the other way to display id: \n");
printf("sum is = %d \n",z);

}

Welcome Note

Hello all !!!

I will not be giving the output of any codes that I post!!!

Please download a C compiler and copy paste the code and see the output.



Here's a link from where you can download a compiler.
I prefer DEV C++ but you can use Microsoft visual stdio,GNU etc
https://sourceforge.net/projects/orwelldevcpp/?source=typ_redirect 

printing on the console

#include<stdio.h>                  
  //preprocessor directive ,stdio.h-->has printf defined in it  preprocessor directive makes the //computer compile .h  files first and then after completion it proceeds towards main

void main()                                                     //main is a function and void is a return type
{
printf("Welcome to kamath c programming tutorial\n");

 //printf is the command that prints the info in the " " and /n is the new line character
}