Monday, 16 March 2015

C program to calculate cumulative interest.

The program is written for calculating the total amount for each year of new scheme proposed by Govt. India.

NEW DELHI: The government has notified 'Sukanya Samriddhi Account', a new small savings instrument for the girl child that could be operated by her after the age of 10. 

Finance Minister Arun Jaitley had announced the scheme in his budget speech in July. 

The account can be opened and operated by the natural or legal guardian of a girl child till she attains the age of 10, after which she can herself operate it but deposits in the account may be made by the guardian or any other person or authority. 

The account could be opened in a post office or a public sector bank. A depositor may open and operate only one account in the name of a girl child under these rules after furnishing birth certificate of the girl child along with other documents relating to identity and residence proof of the depositor. 

Natural or legal guardian of a girl child will be allowed to open accounts for two girl children only except if the depositor has twin girls as second birth or if the first birth itself results into three girl children. 

The government will notify interest rate on this scheme every year. The account may be opened with an initial deposit of Rs 1,000 and thereafter any amount in multiples of Rs 100 may be deposited, subject to the condition that a minimum ofRs 1,000 will be deposited in a financial year but the total money deposited in an account on a single occasion or on multiple occasions shall not exceedRs 150,000 in a financial year. 

Deposits may be made till completion of 14 years from the date of opening of the account, the notification said. The account shall mature on completion of 21 years from the date of opening of the account or if the girl gets married before that. 

Withdrawals up to 50% will be allowed prior to maturity for high education and marriage. 
#include <stdio.h>

int main(void) {
        // it is assumed that Rs.1000 is deposited every month.
       // rate of interest is 9.1% per annum
// your code goes here
int i,j,I,J,P=12000;
for(i=0;i<14;i++)
{
I = P * 9.1/100.0;
P = P + I + 12000;
printf("\n%d",P);
}
for(j=0;j<7;j++)
{
J = P * 9.1/100.0;
P = P + J;
printf("\n%d",P);
}
return 0;
}
 The total amount at the end of 21 years is: 6,53,318.

Monday, 17 November 2014

Cigarette Smokers problem- solution

Three smokers are sitting at a table. One of them has tobacco, another has cigarette papers, and the
third one has matches -- each one has a different ingredient required to make and smoke a cigarette but he may not give any ingredient to another. On the table in front of them, two of the three ingredients will be placed, and the smoker who has the necessary third ingredient should pick up the ingredients from the table, make a cigarette and smoke it. Since a new set of ingredients will not be placed on the table until this action is completed, the other smokers who cannot make and smoke a cigarette with the ingredients on the table must not interfere with the fellow who can. Therefore,
coordination is needed among the smokers. 

Tuesday, 12 August 2014

Develop GUI apps within minutes with Gambas IDE

 For Ubuntu, open your terminal and type the following commands one by one:

sudo add-apt-repository ppa:nemh/gambas3
sudo apt-get update
sudo apt-get install gambas3


useful link

wxPhyton Totorial: Useful for developing GUI for LINUX

http://zetcode.com/wxpython/

Tuesday, 11 February 2014

Yacc programming in windows

download required software : click here

write a yacc program and save it as prg1.y:

%{
// yacc program to implement the grammar
/*
S->(S)
  |a
*/    
#include <stdio.h>
#include <stdlib.h>
%}

%%
Stmt1 : Stmt1 '\n' {   printf ("\n.. Valid Expression.. \n");
                               exit(0);  }
         | S
         | error  {  printf ("\n..Invalid ..\n");
                        exit(0); }
         ;
S : '(' S ')'
   | 'a'
  ;
%%

main ( )
{
  printf("Enter a string to validate : ");
  yyparse ( );
}

yylex()
{    int ch;            
      while(ch=getchar())  
      return ch;      
}
         
yyerror(char *s)
{
    printf( "%s", s );
}

compile the program using the command: bison prg1.y


with this command a C program is created in the current folder with name prg1.tab.c
now compile and run the C program: