003. Technical interview question: Check number is even or odd without using arithmetic or relational operator

#include <stdio.h>
int main()
{
    int number;
    printf("Please input an integer number: ");
    scanf("%d", &number);
    //check 0th bit of number is 1 or 0
    (number & 0x01) ? printf("%d is an EVEN Number.", number) :  printf("%d is an ODD Number.", number) ;
    printf("\n";)
    return 0;
}

002. Technical interview question: Print your name 5 times without a loop

#include <stdio.h>
void printstring(char* name, int count)
{
    printf("%d : %s\n",count+1,name);
    count+=1;
    if(count<=5)
        printstring(name, count);
}
int main()
{
    char name[50]; 
    printf("\n Enter you name :");
    scanf("%s", name);
    printstring(name,1);
    return 0;
}

001. Technical interview questions: Print message without using semicolon

Method 1

    #include <stdio.h>
        int main()
        {
            if(printf("KodeGod\n"))
            { }
        }

Method 2

    #include <stdio.h>
        int main()
        {
            while(!printf("KodeGod\n"))
            { }
        }

Method 3

    #include <stdio.h>
        int main()
        {
            for(;!printf("KodeGod\n");)
            { }
        }

Prepare for Technical Interviews

5 Steps to learning programming easily

Learning programming has never been easy for first-timers. In this blog, we are going to talk about 5 Steps to learning programming easily so that you steadfast your IT career.

Have you still not figured out how you can start your coding career?
Or you have started but stuck in between and do not know how to make it further?

In this article, we are going to focus on exactly this. So, read this article till the end to find out the answer. My personal favorite tip is number 3. Let me know which one you like the most in the comment section.

  1. Choose a language

    You need to start somewhere. So choose a language… any language. Do some research, ask yourself why this specific programming language would be the best for you.
    You can do some basic research on Google that what all can be achieved if you learn this language. Or you can ask people who you already know, preferably to those who have learned this language. But remember do not get carried away by these people as everyone will give some advice. But only few can give you a correct advice.

    From my perspective choose a simple programming language like C. C Language technically does not have much to do with your learning path. But learning it for programming basics will create a strong foundation. It is easy to learn and you can master it in a matter of weeks.

    Or you can use Python, which is my favorite too. The only problem with it is… you might get overwhelmed about what all can be achieved with it. And because you can’t do that all yet, you might start feeling programming as a too distant dream for you. Hence its always better to start small.

    After you choose the language promise yourself “No matter what, I am going to complete learning this language.”

  2. Stick to it till you complete 75% of it at least

    This is again important thing, as… you once start learning a language for the first time, you need to rely much on internal motivation and discipline. As after few days, once you start learning… you come up with questions …Have I really chose the correct language?
    What if I learn this language and it turns out to be non-useful?
    Am I wasting time by learning the language?
    I am learning C-language, but my friends are learning PHP, C#… machine learning
    And Most importantly… will I be able to complete as I planned?

    Then tell yourself…

    I have promised myself that I will complete this language and I will.

  3. Daily dose of code

    Motivation is a very limited resource, it lasts for a while only. And then you need another dose of motivation. Let me explain this by an example… completing 20 lessons in a day does look like a big task and will really require a lot of motivation.

    However, for a simple task like brushing your teeth or checking Facebook messages does not require any motivation, why is that? Because it has become a habit.
    Similarly, if you try to write codes or learning programs as a habit it will become an effortless act. Hence you can promise yourself to understand and write 4 programs a day. Which can take max 45 minutes? That way you will complete 100 programs in 25 days.

    This will be a simpler task and won’t require any motivation. Gradually it forms a habit and sometimes you will even forget that you did 3 programs / 6 programs or even 100 in a single session. You will be so engraved in the process of learning.So, don’t reply to much on motivation, rather form habits which will build interest and a great career later on.

  4. Remembering what can help

    Creating a circle of friends. You may have caught up yourselves with limited or absolutely zero like-minded people. Hence you can join our Facebook communities, WhatsApp groups or YouTube channels and get access to like-minded people.
    Avoid naysayers as they will try to disturb your learning path, in this situation again remember about the promise you made to yourself.

  5. Remeber what cannot help

    Stopping in between. Half knowledge is much more harmful than not knowing anything. As it gives you false confidence that you have learned it, however inside you have the fear of confronting that you do not know it in detail.

    Not letting people know your success or progress you are making throughout your journey. When you share success and progress people will congratulate you and appreciate your efforts, that will make you more confident and motivate you to do more.

    Don’t be a Hitler too and punish yourself with guilt when you skip a session and maybe you are not able to understand a problem. It’s okay, tell yourself things like…Oh, I missed today’s coding session but tomorrow for sure I will make this a priority.

    I am facing difficulty solving or understanding this problem, let me try to put in more efforts else I will seek help from my online communities or take experts advice on this.

    Skipping a coding session is okay but don’t make it a habit.

IMPORTANT Notes

So these are five tips for your journey to learn coding. Apart from these 5 points… there is an important suggestion that can give you to help you learn to code easily.

Based on these tips we at kodegod.com have built a course which has 101 programs which you can learn step by step. The course is concentrated on learning programming logic, which the most important ingredient when you start out learning programming languages, without logic you can’t technically master any programming language or technology. You can register for this course freely and take first 4 modules which consist of 32 lessons at the end of this video which are absolutely free to use.

With the course, you get access to our WhatsApp Group and Facebook Study Groups when you find like-minded people and hence it helps you succeed easily.

This is the link for the course, you can use coupon codes available for additional discounts, you will find the coupons on our blog site.

Most importantly subscribe to our youtube channel and hit the bell icon so get instant notification when we upload similar videos.

Share this video with your all friends so this videos also help them.

Do let me know your suggestions and questions if you have any, using the comment section below.

Thank you so much for watching this video until the end!

Command line arguments – Theory and Programs [Learn to code]

What are Command line arguments? Learn syntax for using Command line arguments, programs on Command line arguments.

  • 101. Write a program accept a file name from user and print content of that file
    #include<stdio.h>
    int main(int argc, char *argv[])
    {
        if ( argc != 2 ){
             printf( "usage: %s filename", argv[0] );
        }
        else 
        {
            FILE *file = fopen( argv[1], "r" );
     
            if(file == NULL)
                 printf("Could not open filen");
            else 
            {
                int x;
                while((x=fgetc(file)) != EOF)
                     printf( "%c", x );
                fclose( file );
            }
        }
    }

File operations – Theory and Programs [Learn to code]

What are File operations? Different modes of File operations and programs on File operations.

  • 098. Write a program to read and write a file character by character.
    #include<stdio.h>
    int main()
    {
        FILE *fp;   /* file pointer*/
        char fName[20];
        char ch;
     
        printf("nEnter file name to create :");
        scanf("%s",fName);
     
        fp = fopen(fName,"w");
        if(fp==NULL)
        {
            printf("File not created !!");
            exit(0); 
        }
     
        printf("File created successfully.");
        /*writing into file*/
        printf("nEnter text to write (press < enter > to save & quit):n");
        while( (ch = getchar())!='n')
        {
            putc(ch, fp); /*write character into file*/
        }
     
    /*again open file to read data*/
        fp = fopen(fName,"r");
        if(fp==NULL)
        {
            printf("nCan't open the file!!!");
            exit(0);
        }
     
        printf("nContents of file is :n");
        /*read text until, end of file is not detected*/
        while( (ch=getc(fp))!=EOF )
        {
            printf("%c",ch); /*print character on screen*/
        }
     
        fclose(fp);
        return 0;
    }
  • 099. Write a program to read and write a file line by line.
    #include <stdio.h>
    int main()
    {
        FILE *fp;
        char str[100];
        fp = fopen("C:\myfile.txt", "w");
     
        if (fp == NULL)
        {
           puts("An error occurred while opening the specified file");
        }
     
         printf("Enter your string:");
     
         gets(str);
     
         fputs(str, fp);
     
         fclose(fp);
     
        fp = fopen("C:\myfile.txt", "r");
     
        if (fp == NULL)
        {
           puts("An error occurred while opening the specified file");
        }
     
        while(1)
        {
           if(fgets(str, 10, fp) ==NULL)
                break;
           else
                printf("%s", str);
        }
     
        fclose(fp);
        return 0;
    }
  • 100. Merge two files by store data into third one
    #include<stdio.h>
    #include<stdlib.h>
     
    int main()
    {
       FILE *fp1 = fopen("file1.txt", "r");
     
       FILE *fp2 = fopen("file2.txt", "r");
     
       FILE *fp3 = fopen("file3.txt", "w");
     
       char c;
       if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
       {
             puts("Could not open files");
             exit(0);
       }
     
       while ((c = fgetc(fp1)) != EOF)
          fputc(c, fp3);
     
       while ((c = fgetc(fp2)) != EOF)
          fputc(c, fp3);
     
       fclose(fp1);
       fclose(fp2);
       fclose(fp3);
       return 0;
    }

Structures – Theory and Programs [Learn to code]

What are Structures? Learn syntax for Structures and different programs on Structures.

  • 095. Define a structure Employee having elements emp_id, name,etc. Accept data and reprint it
    #include<stdio.h>
    #include<conio.h>
     
    struct Employee
    {
     char name[50];
     int emp_id;
     long phone_no;
    };
     
    main()
    {
    	struct Employee e;
    	clrscr();
    	printf("Enter name : ");
    	scanf("%s",&e.name);
    	printf("Enter emp_id: ");
    	scanf("%d",&e.emp_id);
    	printf("Enter Phone Number: ");
    	scanf("%ld",&e.phone_no);
     
    	printf("nnEnter name : %s",e.name);
    	printf("nnEnter Emp Id       : %d",e.emp_id);
    	printf("nnEnter Phone Number : %ld ",e.phone_no);
     
    	getch();
    }
  • 096. Define a structure Student having fields roll_no, name, marks, etc, for 5 students, accept data and reprint
     
    #include<stdio.h>
    #include<conio.h>
     
    struct Student
    {
     char name[50];
     int roll_no;
     int m1,m2,m3;
    };
     
    main()
    {   int i;
    	struct Student s[5];
    	clrscr();
    	for(i=0;i<5;i++)
    	{   printf("nEnter data for Student %d.....n",i+1);
    		printf("Enter name           : ");
    		scanf("%s",&s[i].name);
    		printf("Enter Roll No.       : ");
    		scanf("%d",&s[i].roll_no);
    		printf("Enter marks for sub1 : ");
    		scanf("%d",&s[i].m1);
    		printf("Enter marks for sub2 : ");
    		scanf("%d",&s[i].m2);
    		printf("Enter marks for sub3 : ");
    		scanf("%d",&s[i].m3);
    	}
     
    	for(i=0;i<5;i++)
    	{   printf("nStudent   %dn",i+1);
    		printf("Name    : %sn",s[i].name);
    		printf("Roll No.: %dn",s[i].roll_no);
    		printf("Sub1    : %dn",s[i].m1);
    		printf("Sub2    : %dn",s[i].m2);
    		printf("Sub3    : %dn",s[i].m3);
    	}
     
    	getch();
    }
  • 097. Define a structure Employee having elements emp_id, name, DOB, DOJ etc. Accept data and reprint it. (use structure within structure)
    #include<stdio.h>
    #include<conio.h>
     
    struct Date
    {
    	int mm,dd,yy;
    };
     
    struct Employee
    {
    char name[50];
     int emp_id;
     struct Date DOB,DOJ;
    };
     
    main()
    {   int i;
    	struct Employee e;
    	clrscr();
    		printf("nEnter name           : ");
    		scanf("%s",&e.name);
    		printf("nEnter emp_id.        : ");
    		scanf("%d",&e.emp_id);
    		printf("nEnter Date of Joiningn ");
    		printf("(dd-mm-yy) : ");
    		scanf("%d-%d-%d", &e.DOJ.dd,&e.DOJ.mm,&e.DOJ.yy);
    		printf("nEnter Date of birthn ");
    		printf("(dd-mm-yy) : ");
    		scanf("%d-%d-%d", &e.DOB.dd,&e.DOB.mm,&e.DOB.yy);
     
    		printf("nName           : %s",e.name);
    		printf("nEmployee ID    : %d",e.emp_id);
    		printf("nEnter DOJ      : %d-%d-%d", e.DOJ.dd,e.DOJ.mm,e.DOJ.yy);
    		printf("nEnter DOB      : %d-%d-%d", e.DOB.dd,e.DOB.mm,e.DOB.yy);
     
    	getch();
    }