Saturday, April 29, 2017

Difference between C and Objective C language


C language

Objective C Language

C is a general-purpose programming language.
Objective-C is a general-purpose, high-level, object-oriented programming language.
  • Objective C is basically a set of C, hence everything that is valid C is also valid in Objective-C.
  • Objective C keeps all aspects of C.

C was originally developed by Dennis Ritchie at AT&T Bell Labs between 1969 and 1973.

It was originally developed in the early 1980s by Brad Cox and Tom Love at their company Stepstone.
C is one of the oldest and most widely used programming languages. It has been constantly used in many applications including the UNIX computer operating system.

Mac’ OS X and iOS are derived from the NeXTSTEP operating system and hence use Objective C as their main language.
C doesn’t support classes.

Objective C incorporates classes.
C is procedural programming.

Objective C is object oriented programming.

Friday, April 28, 2017

Program to delete duplicate array elements

#include<stdio.h>

int main()
{
   int arrIn[20], arrOut[20];
   int i, j, k, size, temp,cnt=0, flag=0;

   printf("\nEnter array size(Max 20) : ");
   scanf("%d", &size);

   printf("\nEnter %d Numbers : ", size);
   for (i = 0; i < size; i++)
      scanf("%d", &arrIn[i]);

   printf("\nYour array elements:");
 
   for (i = 0; i < size; i++)
      printf("%d ", arrIn[i]);
     
   //Logic to delete duplicate array elements
   for (i=0; i < size; i++)
   {
     temp = arrIn[i];
     flag = 0;
      for (j=i+1; j<size; j++)
 {
         if (arrIn[j] == temp )
         {
          flag=1; cnt++;
break;
         }
         else
            flag=0;
      }
      if(flag==0)
      arrOut[k++]=temp;
   }
   printf("\n\nArray with unique elements:\n");
   for (i=0; i<size-cnt; i++)
   {
      printf("%d ", arrOut[i]);
   }
   return (0);
}

Output of program

Enter array size(Max 20) : 10

Enter 10 Numbers : 1 2 2 3 3 4 5 5 6 7

Your array elements:1 2 2 3 3 4 5 5 6 7

Array with unique elements:
1 2 3 4 5 6 7


Thursday, April 27, 2017

Reliance Jio IP TV Set top box

India's most discussed buzzword - Reliance Jio might be preparing to launch its IPTV services soon. Some of the images of Reliance Jio Set top box are leaked online. In terms of design, it seems a regular rectangular box. 

The back side of the set top box may have connectivity ports like - standard cable connector port, USB port, HDMI port with audio and video output ports. Jio modem may come with RJ-45 port which means Jio IP TV set-top box can be connected to a modem.

More details about the same is posted on many popular websites. Some of the links are given below:




Friday, April 14, 2017

stack push pop operation

Demonstration of stack push and pop operation.

Program will be added soon...




Accessing structure using Pointer

This program will use members of structure using pointer.

#include <stdio.h>
struct student
{
   int rollno;
   float age;
};

int main()
{
    struct student *ptr_student, student1;
    // Referencing pointer to memory address of student1
ptr_student = &student1;            

    printf("Enter rollno: ");
    scanf("%d",&(*ptr_student).rollno);

    printf("Enter age: ");
    scanf("%f",&(*ptr_student).age);

    printf("Student Details: ");
    printf("%d,%f",(*ptr_student).rollno,(*ptr_student).age);

    return 0;
}

Output of program

Enter rollno: 101
Enter age: 21.5
Student Details: 101,21.50

Thursday, April 13, 2017

String and Pointer

Lets learn how to manipulate string using pointer.

This program will find length of given string using pointer.


#include<stdio.h>
 int main() {
   char str[20], *p;
   int cnt=0;
   
   printf("Enter your string : ");
   gets(str);

   p = &str[0];
   
   while(*p != '\0')
   {
    cnt++;
    p++;
   }
   
   printf("The length of \"%s\" is: %d", str, cnt);
   return 0;
}

Output of program

Enter your string : hello students
The length of "hello students" is: 14


Dynamic Memory Allocation for Structure


#include <stdio.h>
#include<stdlib.h>

struct book
{
   int id;
   char title[30];
};

int main()
{
   struct book *ptr;
   int i, n;
   printf("Enter number of books: ");
   scanf("%d", &n);

   // Dynamic Memory allocation for n books
   
   ptr = (struct book*) malloc (n * sizeof(struct book));

   for(i = 0; i < n; ++i)
   {
       printf("Enter book ID:");
       scanf("%d", &(ptr+i)->id);
       printf("Enter book Title:");
       scanf("%s", &(ptr+i)->title);
   }

   printf("\nBook Details(ID, Title):\n");

   for(i = 0; i < n ; ++i)
       printf("%d, %s\n", (ptr+i)->id, (ptr+i)->title);

   return 0;
}

Output of Program

Enter number of books: 3
Enter book ID:101
Enter book Title:Computer
Enter book ID:102
Enter book Title:Science
Enter book ID:103
Enter book Title:Security

Book Details(ID, Title):
101, Computer
102, Science
103, Security

Wednesday, April 12, 2017

Array of Structure

This program will demonstrate Array of Structure.

#include <stdio.h>
#include <string.h>

struct Book{
   int   book_id;
   char  book_title[30];
   char  book_publisher[30];
   char  book_subject[30];
};

int main( ) {

// Declare 3 variables of Book structure

 struct Book myBook[3];  
int i;

//Initialise values to myBook variable
for(i=0; i<3; i++)
{
printf("\nEnter Details of Book%d:\n",i+1);
printf("ID:");
scanf("%d",&myBook[i].book_id);

printf("Title:");
  scanf("%s",myBook[i].book_title);
  
  printf("Publisher Name:");
    scanf("%s",myBook[i].book_publisher);
  
    printf("Subject:");
    scanf("%s", myBook[i].book_subject);
}
   
   /* print myBook details */
   for(i=0; i<3; i++)
   {
    printf("\nDetails of Book%d:\n",i+1);
    printf( "ID: %d\n", myBook[i].book_id);
    printf( "Title: %s\n", myBook[i].book_title);
    printf( "Publisher Name : %s\n", myBook[i].book_publisher);
    printf( "Subject : %s\n", myBook[i].book_subject);
    printf("\n");
   }
   return 0;
}

Output of program


Enter Details of Book1:
ID:101
Title:Math-1
Publisher Name:ABC
Subject:Mathematics

Enter Details of Book2:
ID:102
Title:DataScience
Publisher Name:XYZ
Subject:Science

Enter Details of Book3:
ID:103
Title:Security
Publisher Name:ABC
Subject:Cryptography

Details of Book1:
ID: 101
Title: Math-1
Publisher Name : ABC
Subject : Mathematics


Details of Book2:
ID: 102
Title: DataScience
Publisher Name : XYZ
Subject : Science


Details of Book3:
ID: 103
Title: Security
Publisher Name : ABC
Subject : Cryptography


Saturday, April 8, 2017

Swastik Pattern 2

Following program will print Swastik pattern based on given value of N.



#include<stdio.h>
int main()
{
int i,j,n;
printf("Enter Swastik Size(n):");
scanf("%d",&n);
printf("** ");

for(i=0; i<n-2; i++)
printf("   ");

for(i=0; i<n; i++)
printf("** ");

printf("\n");
printf("** ");

for(i=0; i<n-2; i++)
printf("   ");

for(i=0; i<n; i++)
printf("** ");

printf("\n");
for(j=0; j<n-2; j++)
{
printf("** ");
for(i=0; i<n-2; i++)
printf("   ");
printf("** \n");
}

for(i=0; i<n*2-1; i++)
printf("** ");
printf("\n");
for(i=0; i<n*2-1; i++)
printf("** ");
printf("\n");

for(j=0; j<n-2; j++)
{
for(i=0; i<=n-2; i++)
printf("   ");
printf("** ");
for(i=0; i<n-2; i++)
printf("   ");
printf("** \n");
}

for(i=0; i<n; i++)
printf("** ");
for(i=0; i<n-2; i++)
printf("   ");
printf("** \n");
for(i=0; i<n; i++)
printf("** ");
for(i=0; i<n-2; i++)
printf("   ");
printf("** ");
        return 0;
}

Output of program

Enter Swastik Size(n):5
**          ** ** ** ** **
**          ** ** ** ** **
**          **
**          **
**          **
** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** **
            **          **
            **          **
            **          **
** ** ** ** **          **
** ** ** ** **          **

Tuesday, April 4, 2017

Flowchart to subtract two numbers.


Flowchart to subtract two numbers

Flowchart to subtract two numbers

Fig. Flowchart to subtract two numbers

Flowchart to Add two numbers.

Flowchart to Add two numbers 

This flowchart outlines the essential steps required to add two numbers.

Flowchart to add two numbers

Fig. Flowchart to Add two numbers


Top 10 Flowchart Examples on 


youtube.com/@SelfStudyTutorials
 




< Home Page >


Flowchart to print area of square.

Flowchart to print area of rectangle.


Flowchart to Print Area of Rectangle

Flowchart to print area of rectangle


Fig. Flowchart to print Area of Rectangle

Key Symbols used in this flowchart are:

  • Oval: Represents the start and end points of the flowchart.
  • Parallelogram: Used for input and output operations.
  • Rectangle: Denotes processes or calculations.
  • Arrows: Show the flow of control and data between steps.

Back to Flowchart Page

Sunday, April 2, 2017

Escape Sequences

Followings are some of the escape sequences characters used in C language.

Escape Sequence
Characters
Description
Example
Output
\n
New line
printf(“Hello \n Student”);
Hello
Student
\t
Tab
printf(“Hello \t Student”);
Hello     Student
\a
Alert (Beep) sound
printf(“\a”);
You will listen a Beep sound
\0
Null
printf(“Hello \0 World”);
Hello
\r
Carriage return
printf("Gujarat\rINDIA");
INDIAat
\"
To insert double quote
printf("\"INDIA\"");
"INDIA"
\'
To insert single quote
printf("Gujarat\'s");
Gujarat's
\\
To print \
printf("On\\Off");
On\Off







Saturday, April 1, 2017

Reserved Words (Keywords) in C

                 
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

Important points to remember
  • C is case sensitive.
  • All keywords and Standard Library functions are in lowercase.
  • These reserved keywords cann’t be used as variable or function name of C program.